package com.akkainaction.tool.extension.spring.actor;

import akka.actor.UntypedActor;
import com.akkainaction.tool.extension.spring.service.EmpService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@Component("actorDemo")
@Scope("prototype")//这里要注意，在定义Actor Bean时，务必要将其设置为非单例的状态，否则程序会出问题。
public class ActorDemo extends UntypedActor {

    @Resource
    private EmpService empService;

    @Override
    public void onReceive(Object msg) throws Exception {
        System.out.println(getSelf() + "接收到消息:[" + msg + "]");
        empService.saveEmp((String) msg);
    }
}
